package com.bm.console.action;

import java.io.IOException;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.bm.console.business.WeatherService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.bm.console.business.ExchangeRateService;


@Component
@EnableScheduling
@Slf4j
public class TaskAction {

    @Autowired
    private ExchangeRateService exchangeRateService;

    @Autowired
    private WeatherService weatherService;

    @Scheduled(cron = "0 30 13 * * ? ")
    public void download_LosAngeles_Data() throws IOException {
        log.info("更新汇率信息");
        exchangeRateService.saveCapture();
    }

    @Scheduled(cron = "0 10 9 * * ? ")
    public void downloadWeather() throws IOException {
        log.info("更新天气信息");
        weatherService.save();
    }

}
